package cn.gxljc.technology.store_management.mapper;

import cn.gxljc.technology.store_management.entity.AccountPermissions;
import org.apache.ibatis.annotations.*;

/*
 * @author LuoShengYing
 * @date 2021/05/22
 * AccountPermissionsMapper用于管理AccountPermissions(用户权限)表
 * */
@Mapper
public interface AccountPermissionsMapper {

    // 通过accountID，查询对应的AccountPermissions数据
    @Select("select `accountID`, `permissions`" +
            "from `accountpermissions` where `accountID` = #{accountID}")
    AccountPermissions selectByAccountID(@Param("accountID") long accountID);

    // 新增一条AccountPermissions数据，并返回boolean类型数据判断成功与否
    @Insert("insert `accountpermissions`" +
            "set `accountID` = #{accountID}, `permissions` = #{permissions}")
    boolean insertAccountPermissions(AccountPermissions accountPermissions);

    // 通过accountID，更新AccountPermissions数据中的permissions，并返回boolean类型数据判断成功与否
    @Update("update `accountpermissions`" +
            "set `permissions` = #{permissions} where `accountID` = #{accountID}")
    boolean updatePermissions(@Param("accountID") long accountID, @Param("permissions") int permissions);

    // 通过accountID，删除对应的AccountPermissions数据，并返回boolean类型数据判断成功与否
    @Delete("delete from `accountpermissions`" +
            "where `accountID` = #{accountID}")
    boolean deleteAccountPermissions(@Param("accountID") long accountID);
}
